<include file="public:header"/>
<script language="javascript" type="text/javascript" src="__ROOT__/statics/js/jquery/plugins/formvalidator.js"></script>
<script language="javascript" type="text/javascript" src="__ROOT__/statics/js/jquery/plugins/formvalidatorregex.js"></script>
<load href="__TMPL__public/css/account.css" /> 
<link href="__ROOT__/statics/css/formvalidator.css" rel="stylesheet" type="text/css" />

<div class="middle">
    <div class="uc_account clearfix">
		<include file="account_left"/>	
        <div class="right_region account">
			<present name="err">
            <div class="err"  style="width:150px;">
		        <div class="icon_{$err.err}">{$err.msg}</div>                
            </div>
            </present> 

         <if condition="$show_page == 1">
            <form name="mobile_form" id="mobile_form" action="{:u('uc/account_mobile')}" method="post">
                <table>
                    <tr>
                        <th style="width:100px;">请输入手机号：</th>
                        <td><input type="text" value="" id="mobile" name="mobile" class="input_text"/></td>
                    </tr>
                          <tr>
                        <th></th>
                        <td><input type="button" value="免费获取验证码" id="but_get_verify"/></td>
                    </tr>
                    <tr>
                        <th>填写验证码：</th>
                        <td><input type="text" value="" id="verify" name="verify" class="input_text"/></td>
                    </tr>                                
                    <tr>
                        <th></th>
                        <td><input type="submit" value="确定" name="dosubmit" id="btn_submit"/>  
                        <input type="reset"  value="重新输入手机号" name="dosubmit" id="btn_reset"/></td>
                    </tr>
                </table>            
            </form>  
            <script type="text/javascript">
var gwait=60,rwait=60;
$(function(){ 
	$.formValidator.initConfig({formid:"mobile_form",autotip:true,
		onerror:function(msg,obj){
			art.dialog({content:msg,lock:true,width:'200',height:'50'}, 
					   function(){this.close();$(obj).focus();})
			}
	});
		
	$("#mobile").formValidator({onshow:"请输入绑定的手机号码",onfocus:"请输入绑定的手机号码",onempty:"请输入绑定的手机号码"}).inputValidator({min:11,max:11,onerror:"手机号码必须是11位的,请确认"})
	.regexValidator({regexp:"^[1][0-9]{10}$",onerror:"你输入的手机格式不正确"});
	$("#verify").formValidator({onshow:"请填4位验证码",onfocus:"请填4位验证码"})
		.inputValidator({min:4,max:4,onerror:"请填4位验证码"})
		.ajaxValidator({
			  type : "get",
			  dataType:"json",
			  async:true,
			  addidvalue : true,
			  url:"{:u('uc/account_mobile')}",//无法取值
			  success : function(data){
				  var jsonData = eval("("+data+")");
				  if(jsonData.status==0)
					  return false;
				  if(jsonData.status==1)
				      return true;
			  },
			  buttons: $("#btn_submit"),
			  error: function(jqXHR, textStatus, errorThrown){alert("服务器没有返回数据，可能服务器忙，请重试"+errorThrown);},
			  onError : "该手机号不可用，请更换手机号",
			  onWait : "正在对校验验证码，请稍候..."
			 });
});

$(function(){
	$("#btn_reset").click(function(){
		$("#mobile").removeAttr("readonly");  
	});
	$("#but_get_verify").click(function(){
		  var mobile =$("#mobile").val(); 
		 if(mobile==''){
			 art.dialog({content:'请输入手机号!',lock:true,width:'200',height:'50'}, 
					   function(){this.close();$(obj).focus();})
			 return; 
		 }
		 var obj = $(this);
		 $.getJSON("{:u('uc/account_mobile_send')}&mobile="+mobile, function(result){
			    $("#mobile").attr("readonly","readonly");
			    if(result.status>=1){
			    	rtime(obj,"重新获取验证码",gwait);
			    	rtime($("#btn_reset"),"重新输入手机号",rwait);
			    }
			   
			    art.dialog({content:result.info,lock:true,width:'200',height:'50'}, 
						   function(){this.close();$(obj).focus();})
		 });
		 
	});

});

function rtime(o,t,wait){
	if (wait == 0) {
		o.attr('disabled',false);		
		o.val(t);
		wait = 60;
	} else {
		o.attr('disabled',true);
		o.val(t+"(" +wait + ")");
		wait--;
		setTimeout(function() {
			rtime(o,t,wait);
		},
		1000)
	}
}
</script>
</if>
<if condition="$show_page == 2">
 <tr>
                        <th>手机号：</th>
                        <td>{$user.mobile}<a href="{:u('uc/account_mobile')}&ddo=m">[修改手机号]</a></td>
                    </tr>
  </if>                  
        </div>
    </div>
</div>

<include file="public:footer"/> 